<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
  <head>
    <?php $this->load->view('user/_html_head') ?>
    <script type="text/javascript">
      var time_<?php echo $promotion['id'] ?> = <?php echo $promotion['end_date'] - time() ?>;
      $(document).ready(function() {
        jQuery('#form_comment').validationEngine();
        $('#slideshow_<?php echo $promotion['id'] ?>').cycle({fx: 'fade' /* fade, scrollUp, shuffle, etc...*/});
        setInterval(function() {
          setTimeAuction( "#remain_time_<?php echo $promotion['id'] ?>" , time_<?php echo $promotion['id'] ?> );
          time_<?php echo $promotion['id'] ?> -= 1;
        }, 1000);  
      });            
    </script>
    <script>!function(d,s,id){var js,fjs=d.getElementsByTagName(s)[0];if(!d.getElementById(id)){js=d.createElement(s);js.id=id;js.src="//platform.twitter.com/widgets.js";fjs.parentNode.insertBefore(js,fjs);}}(document,"script","twitter-wjs");</script>
  </head>
  <body>
    <div id="fb-root"></div>
    <script>
      window.fbAsyncInit = function() { FB.init({appId: '289823484465602', status: true, cookie: true, xfbml: true}); };
      (function() {
        var e = document.createElement('script'); e.async = true;
        e.src = document.location.protocol + '//connect.facebook.net/en_US/all.js';
        document.getElementById('fb-root').appendChild(e);
      }());
      
      (function(d, s, id) {
        var js, fjs = d.getElementsByTagName(s)[0];
        if (d.getElementById(id)) return;
        js = d.createElement(s); js.id = id;
        js.src = "//connect.facebook.net/en_US/all.js#xfbml=1&appId=289823484465602";
        fjs.parentNode.insertBefore(js, fjs);
      }(document, 'script', 'facebook-jssdk'));
    </script>
    <div class="wrapper_screen">
      <div class="wrapper_main">
        <?php $this->load->view('user/_header') ?>
        <div class="contenu">
          <div class="w700_2 cpos_1" style="width:762px">
            <?php $this->load->view('user/_detail_promotion', array('promotion' => $promotion)); ?>
            <div class="head_box"></div>
            <div class="w710" style="width: 762px">
              <div class="w217 cpos_1" style="padding-left: 9px;padding-top:0px;">
                <div class="font18 mg_bt30" style="margin-top:0px;color:white">
                  <?php echo $promotion['provider']['company_name'] ?></div>
                <div><?php echo $promotion['provider']['address'] ?></div>
                <div><?php echo $promotion['provider']['home_page'] ?></div>
                <div><?php echo $promotion['provider']['phone'] ?> - <?php echo $promotion['provider']['fax'] ?></div>
                <div class="mg20">
                  <form action="<?php echo site_url('promotion/comment/' . $promotion['id'] . '/' . str_nice_name($promotion['title'])) ?>" id="form_comment">
                    <label>Title:</label><br/>
                    <input name="title" id="title" value="" placeholder="" style="width: 100%" class="validate[required]"></input><br/>
                    <label>Content:</label><br/>
                    <textarea name="content" placeholder="" id="content" style="width: 100%;height: 100px" class="validate[required]"></textarea>
                    <label>Captcha</label><br/>
                    <input id="captcha" type="text" name="captcha" value="" placeholder="captcha" style="width: 100%"
                           class="validate[required]"/><br/>
                           <?php echo $captcha['image'] ?>
                    <input type="submit" value="<?php echo $this->lang->line('front-end.btn.comment') ?>" 
                           class="more btn_disable" style="margin-left: 35px" name="btn_reg_submit"/>
                  </form>

                </div>
                <?php foreach ($promotion['comments'] as $comment) { ?>
                  <div class="border_51e4f7" style="margin-top: 10px;border:1px solid white;width: 188px">
                    <div class="cpos_2" style="width: 100%">
                      <a href="#"><?php echo $comment['title'] ?></a>
					  <span style="float:right;font-size:80%"><?php echo date('d/m/Y h:i:s') ?></span>
					  </div>  
                    <div><?php echo $comment['content'] ?></div>
                    <div class="cpos_2"><a href="#"><?php echo $this->end_user_model->to_string($comment['end_user_id']) ?></a></div>
                    <div class="clearer"></div>
                  </div>
                <?php } ?>
              </div>
              <div class="w493 cpos_2" style="width: 505px;padding-top: 0px">
                <div class="mg10" style="margin-top: 0px"><?php echo $promotion['description'] ?></div>
                <?php if (!empty($promotion['lat']) && !empty($promotion['lng'])) { ?>
                  <script src="//maps.google.com/maps?file=api&amp;v=2&amp;sensor=false&amp;key=<?php echo $this->setting_model->item('googlemap_api') ?>"
                  type="text/javascript"></script>
                  <script type="text/javascript">
                    var map, marker;
                    function create_marker(point){
                      marker = new GMarker(point, {draggable: false});    
                      map.addOverlay(marker);
                    }
                    function initialize() {
                      if (GBrowserIsCompatible()) {
                        map = new GMap2(document.getElementById("map"));
                        map.addControl(new GMapTypeControl());
                        map.addControl(new GScaleControl());
                        map.enableScrollWheelZoom();
                        var customUI = map.getDefaultUI();
                        customUI.maptypes.hybrid = false;
                        map.setUI(customUI);
                        var center = new GLatLng( <?php echo $promotion['lat'] ?>, <?php echo $promotion['lng'] ?> );
                        map.setCenter(center, 13);
                        create_marker(center);
                      }
                    }
                    jQuery(document).ready(function(){
                      $('#map').css('width', '505px').css('height','221px');
                      initialize();
                    });  
                  </script>
                  <div id="map" class="mg10"></div>
                <?php } ?>
              </div>
              <div class="clearer"></div>
            </div>          
            <div class="footer_box"></div>
            <script type="text/javascript">
<?php foreach ($promotion['relates'] as $p) { ?>
                var time_<?php echo $p['id'] ?> = <?php echo $p['end_date'] - time() ?>;
                jQuery(document).ready(function(){
                  $('#slideshow_<?php echo $p['id'] ?>').cycle({fx: 'fade'});
                });
<?php } ?>
              jQuery(document).ready(function(){                
                setInterval(function() {
<?php foreach ($promotion['relates'] as $p) { ?>
                    setTimeAuction( "#remain_time_<?php echo $p['id'] ?>" , time_<?php echo $p['id'] ?> );
                    time_<?php echo $p['id'] ?> -= 1;
<?php } ?>
                }, 1000);              
              });
            </script>
            <div style="float: left">
              <?php
              foreach ($promotion['relates'] as $i => $p) {
                $this->load->view('user/_promotions', array('promotion' => $p, 'i' => $i));
              }
              ?>
              <div class="paging_page" style="width: 100%;float:left"><?php echo $paging ?></div>
            </div>
          </div>          
<?php $this->load->view('user/_right_index') ?>
        </div>
      </div>
    </div>
<?php echo $this->load->view('user/_footer') ?>    
  </body>
</html>
